/*
 *  This file is part of VADER.
 *
 *  VADER is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  VADER is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package vegadataeditor;

import java.util.Date;
import java.text.SimpleDateFormat;
import java.sql.ResultSet;
import java.util.List;

/**
 *
 * @author lawinslow
 */
public class VegaStreamContainer {

    public boolean selected = false;
    
    public int streamID;
    public String site;
    public String variable;
    public int method;
    public String source;
    public String offsetType;
    public double offsetValue;
    public String unit;
    public int AggSpanInSec;
    public String AggMethod;
    /** The earliest date for which data are available. */
    public Date earliestDate;
    /** The latest date for which data are available.  */
    public Date latestDate;
    
    public ResultSet retrieved;
    public Date startRetrieved = new Date();
    public Date endRetrieved = new Date();
    public long[] datetime;
    public double[] values;
    public List<String> flags;
    
    public boolean hasNoValues = false;
    public boolean hasMetadataException = false;
    
    @Override
    public String toString(){
        if(hasMetadataException){
            return "No Metadata due to unknown database issue.";
        }
        String toReturn = site + ":" + variable;
        String methodStr = "";
        
        if(method!=0){
            methodStr = " gid:" + method;
        }
        
        //format hour as 00, 01, or 10 keeping length at least 2
        String hour = Integer.toString(AggSpanInSec/3600);
        if(hour.length() < 2){
            hour = "0"+hour;
        }
        
        //format minute in two digit form just like hour
        String minute = Integer.toString(AggSpanInSec%3600/60);
        if(minute.length()<2){
            minute = "0" + minute;
        }
        
        if(offsetType != null){
           toReturn +=  "("+ offsetValue + ")";
        }
        SimpleDateFormat startEndDate = new SimpleDateFormat("MM/dd/yyyy");
        
        toReturn +="(" + unit + ")" + hour + ":" + minute
                + ":" + AggMethod + methodStr;
        
        /*
        if(!hasNoValues){
            
            toReturn += " Start:"+startEndDate.format(earliestDate) + " End:" + 
                    startEndDate.format(latestDate);            
        }
         */

           
        return toReturn;

    }
    
}
